# cmake version
cmake_minimum_required(VERSION 3.10)
project(LibAPI_pro)

#Check arch and system 
include(${CMAKE_SOURCE_DIR}/cmake/CompilerDetection.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/Findlibrary.cmake)

#Turn on the verbose output mode of CMake.
set(CMAKE_VERBOSE_MAKEFILE ON)
# set cmake parameters
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}  -pthread -rdynamic -no-pie -funwind-tables -ldl")
#Redefine the _ _ FILE__ macro
set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS}  -Wno-deprecated  -Wno-unused-function -Wno-builtin-macro-redefined -Wno-deprecated-declarations")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-builtin")
# Set up to generate location-independent code, which is useful for creating shared libraries because it ensures that the code does not depend on its absolute location in memory.
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# If the currently specified C++ standard is not available, the configuration fails.
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Allows the compiler to support its specific C++ language extensions. This means that the compiler can provide functionality beyond the official C++ standard.
set(CMAKE_CXX_EXTENSIONS ON)
#When this property is TRUE, it tells CMake to use the installed RPATH when building. This is usually used with CMAKE_INSTALL_RPATH.
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) 



# Add a configuration header file to handle CMake's settings for the source code
configure_file(
  "${CMAKE_SOURCE_DIR}/config.h.in"
  "${CMAKE_SOURCE_DIR}/include/config.h"
)


include_directories(${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CMAKE_SOURCE_DIR}/src/Module)
# find  lib
#set(NLOHMANNJSON_INCLUDES   ${CMAKE_SOURCE_DIR}/third_party/nlohmann)
#list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")


#Compile Module
add_subdirectory(src)

set(TOOLS_EXE api_tools)
add_subdirectory(tools)
message("LIBRARY_OUTPUT_PATH:" ${PROJECT_BINARY_DIR})
# 添加依赖关系
add_dependencies(${TOOLS_EXE} install_src)